﻿#region Header
// Copyright 2007-2011, Jerónimo Milea
// 
// This file is part of NetJsWire.
// 
//     NetJsWire is free software: you can redistribute it and/or modify
//     it under the terms of the GNU General Public License as published by
//     the Free Software Foundation, either version 3 of the License, or
//     (at your option) any later version.
// 
//     NetJsWire is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU General Public License for more details.
// 
//     You should have received a copy of the GNU General Public License
//     along with NetJsWire.  If not, see <http://www.gnu.org/licenses/>.
#endregion

using System;
using System.ComponentModel;
using NetJsWire.JsonRpcHandler;
using NetJsWire.JsonRpcHandler.Attributes;
using NetJsWire.JsonRpcHandler.Util;
using NetJsWire.Widgets.Config;
using NetJsWire.Widgets.Core;
using NetJsWire.Widgets.Ui.Layout;

namespace NetJsWire.Widgets.Ui.Tabs
{
    [ Renderer( typeof (Renderers.Tabs.TabPage) ) ]
    public partial class TabPage : System.Windows.Forms.TabPage, IWidget, IWidgetContainer
    {
        private readonly IRenderer _renderer;
        private PanelConfigOptions _configOptions;
        private LayoutType _layout = LayoutType.Auto;

        public TabPage()
        {
            InitializeComponent();

            _renderer = Helper.GetRenderer( this );
        }

        public TabPage( IContainer container )
        {
            container.Add( this );

            InitializeComponent();

            _renderer = Helper.GetRenderer( this );
        }

        [DefaultValue( false )]
        public bool Closable { get; set; }

        #region IWidget Members

        public IRenderer Renderer
        {
            get { return _renderer; }
        }

        public void On( string name, string function )
        {
            throw new NotImplementedException();
        }

        public void AddClass( string cls )
        {
            throw new NotImplementedException();
        }

        public void RemoveClass( string cls )
        {
            throw new NotImplementedException();
        }

        [ DefaultValue( false ) ]
        [ Description(
            "If the framework should generate a global Javascript variable that points to the Widget, the name of the variable will be the same as ClientID property of the Renderer."
            ) ]
        public bool GenerateClientMember { get; set; }

        [ RefreshProperties( RefreshProperties.All ),
          DesignerSerializationVisibility( DesignerSerializationVisibility.Content ), Category( "Config" ) ]
        public IConfigOptions ConfigOptions
        {
            get
            {
                if ( _configOptions == null )
                {
                    _configOptions = new PanelConfigOptions( this );
                    _configOptions.Xtype = "panel";
                }
                return _configOptions;
            }
        }

        #endregion

        #region IWidgetContainer Members

        [ DefaultValue( LayoutType.Auto ) ]
        public new LayoutType Layout
        {
            get { return _layout; }
            set { _layout = value; }
        }

        public string LayoutConfig { get; set; }

        #endregion
    }
}